package pannelli.main;
import it.jack.PannelloPrincipale;

import java.awt.Dimension;
import java.awt.Point;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import com.cloudgarden.layout.AnchorConstraint;
import com.cloudgarden.layout.AnchorLayout;
import javax.swing.JButton;

import javax.swing.WindowConstants;
import javax.swing.SwingUtilities;
import javax.swing.event.InternalFrameEvent;
import javax.swing.event.InternalFrameListener;

import pannelli.AggiungiUtente;
import pannelli.sub.SubPannelloVisualizzaUtenti;



/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class PannelloUtenti extends javax.swing.JInternalFrame implements InternalFrameListener{
	private SubPannelloVisualizzaUtenti subPannelloVisualizzaUtenti1;
	private JButton rimuovi;
	private JButton aggiungi;
	private static PannelloUtenti instance;

	/**
	* Auto-generated main method to display this JFrame
	*/
		
	public static PannelloUtenti getInstance(){
		return instance;
	}
	public PannelloUtenti() {
		super("Pannello Utenti",true,true,true,true);
		this.instance=this;
		initGUI();
		centra();
		this.addInternalFrameListener(this);
	}
	public void initTable(){
		subPannelloVisualizzaUtenti1.initTable();
	}
	public void centra(){
		Dimension dimension = Toolkit.getDefaultToolkit().getScreenSize();
		setLocation(new Point((dimension.width - getSize().width) / 2, 
				(dimension.height - getSize().height) / 2 ));
	}
	
	private void initGUI() {
		try {
			AnchorLayout thisLayout = new AnchorLayout();
			getContentPane().setLayout(thisLayout);
			setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
			{
				aggiungi = new JButton();
				getContentPane().add(aggiungi, new AnchorConstraint(100, 968, 196, 776, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL));
				aggiungi.setText("Aggiungi Utente");
				aggiungi.setPreferredSize(new java.awt.Dimension(129, 32));
				aggiungi.addActionListener(new ActionListener() {
					
					@Override
					public void actionPerformed(ActionEvent arg0) {
						new AggiungiUtente();
					}
				});
			}
			{
				subPannelloVisualizzaUtenti1 = new SubPannelloVisualizzaUtenti();
				getContentPane().add(subPannelloVisualizzaUtenti1, new AnchorConstraint(7, 722, 983, 6, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL));
				subPannelloVisualizzaUtenti1.setPreferredSize(new java.awt.Dimension(482, 325));
			}
			pack();
			this.setSize(673, 355);
		} catch (Exception e) {
		    //add your error handling code here
			e.printStackTrace();
		}
	}
	public void setFlag(boolean b) {
		subPannelloVisualizzaUtenti1.setFlag(b);
	}
	@Override
	public void internalFrameActivated(InternalFrameEvent arg0) {
		PannelloPrincipale.getIstance().disableButtons();
	}
	@Override
	public void internalFrameClosed(InternalFrameEvent arg0) {
		// TODO Auto-generated method stub
		
	}
	@Override
	public void internalFrameClosing(InternalFrameEvent arg0) {
		PannelloPrincipale.getIstance().activateButtons();
		this.dispose();
	}
	@Override
	public void internalFrameDeactivated(InternalFrameEvent arg0) {
		// TODO Auto-generated method stub
		
	}
	@Override
	public void internalFrameDeiconified(InternalFrameEvent arg0) {
		// TODO Auto-generated method stub
		
	}
	@Override
	public void internalFrameIconified(InternalFrameEvent arg0) {
		// TODO Auto-generated method stub
		
	}
	@Override
	public void internalFrameOpened(InternalFrameEvent arg0) {
		PannelloPrincipale.getIstance().disableButtons();
	}
}
